@directive dynamic user;
<!DOCTYPE html>
<html>
<head>@ include("/weixin/include/header.html",{"title":isOp?"协办流程":"查看流程"}){}
</head>
<body>
	<div  class="flow_title">${flow.title}</div>
	<div class="flow_container v_dir">
		<div class="flow_detail_row">
			<div class="flow_detail_label">发起人：</div>
			<div class="flow_detail_content">${flow.cname}</div>
		</div>
		<div class="flow_detail_row">
			<div class="flow_detail_label">发起时间：</div>
			<div class="flow_detail_content">${flow.ctime,"yyyy-MM-dd HH:mm"}</div>
		</div>
		<div class="flow_detail_row">
			<div class="flow_detail_label">说明：</div>
			<div class="flow_detail_content">${flow.des}</div>
		</div>
		
		<div class="flow_detail_row">
			<div class="flow_detail_label">附件：</div>
			<div class="flow_detail_attaches">
					@for(var attach in flow.attachList!){
							<div class="attach_item h_align_center"><a href="${basePath}${attach.url}">${attach.name}</a></div>
						
						@}
			</div>
		</div>
	</div>
	@for(var segment in segmentList){
		@if(segment.stat == 0){
			@if(isOp){
			<form id="form1" method="post" action="${basePath}/weixinFlow/doOp" enctype="multipart/form-data"> 
			<input
			type="hidden" name="targetId" id="targetId" value="">
			<input type="hidden" name="segId" value="${segment.id}"> 
			<input type="hidden" name="flowId" value="${flow.id}"> 
		<div class="weui_cells weui_cells_form" style="margin-top: 14px;">
			<div class="weui_cell" style="margin-top: 14px;">
				<div class="weui_cell_bd weui_cell_primary">
					<textarea class="weui_textarea" placeholder="请输入处理意见" rows="4"
						name="comment"></textarea>
				</div>
			</div>
		</div>
<div class="attaches "><a class="btn_add_attach align_center" onclick="addAttach()">添加附件</a>
		<div id="file_container" class="attach_item h_align_center"></div>
		<div class="attach_item h_align_center" id="img_container">
		</div>
		
	</div>
<input type="file"  multiple="true" name="attach" onchange="onChange()" id="attach_file" style="display: none;">
<input type="hidden" name="serverId" id="serverId">
<input type="hidden" name="wxFileId" id="wxFileId">

	</form>
	<div class="flow_over tea active" id="flow_over" data=""><a onclick='flowOver()'></a><span>流程结束</span></div>
	<div class="tree" style="margin-top: 14px" id="tree"></div>
<div id="file_list" class='weui-popup-container file_container'>
	<div class="wxfile_container_inner v_dir">
		<div id="wxfile_container">
		@  for(file in fileList){
			<a onclick="checkFile(this)">
				<div class="file_item h_align_center" id="wx_${file.attach_id}">
					<i></i>
					<div class="file_thumb align_center">
						<img src="${basePath}${file.thumb_url}">
					</div>
					
					<div class="align_center file_des">
						<span>上传时间：${file.ctime,"yyyy-MM-dd HH:mm"}</span>
					</div>
				</div>
			</a>
		@  }
			
		</div>
		
			<script type="text/javascript">
				var wxFileData =  [
					@  for(file in fileList){
						{"id":"${file.attach_id}","name":"${file.name}"},
					@  }
		];
			</script>
			<a id="btn_wxfile_close" onclick="closePopup()"class="weui_btn weui_btn_primary" style="margin: 16px;">关闭</a>
		</div>
    </div>
	<a href="javascript:submit();" class="weui_btn weui_btn_primary"
		style="margin: 16px;">提交</a>
			
			
			
			@}else{
				<div class="flow_container segment">
					<div class="flow_detail_row">
						<div class="flow_detail_label">处理人：</div>
						<div class="flow_detail_content">${segment.operator}</div>
					</div>
					<div class="flow_view_wait">处理中</div>
				</div>
			@}
		@}else{
			<div class="flow_container segment">
				<div class="flow_detail_row">
					<div class="flow_detail_label">处理人：</div>
					<div class="flow_detail_content">${segment.operator}</div>
				</div>
				<div class="flow_detail_row">
					<div class="flow_detail_label">处理时间：</div>
					<div class="flow_detail_content">${segment.ctime,"yyyy-MM-dd HH:mm"}</div>
				</div>
				<div class="flow_detail_row">
					<div class="flow_detail_label">处理意见：</div>
					<div class="flow_detail_content">${segment.comment}</div>
				</div>
				
				<div class="flow_detail_row">
					<div class="flow_detail_label">附件：</div>
					<div class="flow_detail_attaches">
						@for(var attach in segment.attachList){
							<div class="attach_item h_align_center"><a href="${basePath}${attach.url}">${attach.name}</a></div>
						
						@}
					</div>
				</div>
			</div>
		@}
	
	@}

	@if(isOp){
	@	include("/weixin/include/js_import.html"){}
	<script type="text/javascript">
	var nodeData = [
					
@  for(node in nodeList){
					{"id":"${node.id}","name":"${node.name}","pid":["${node.pid}"],"type":"${node.type}"},
@  }
		];
	
	function flowOver(){
		$(".item.active").removeClass("active");
		if(!$("#flow_over").hasClass("active")){
			$("#flow_over").addClass("active");
		}
	}
		
		function aClick(icon,e){
			if(e != undefined){
				e.stopPropagation();
			}
			if($("#flow_over").hasClass("active")){
				$("#flow_over").removeClass("active");
			}
			$(".item.active").removeClass("active");
			
			var item = $(icon).parent();
			item.addClass("active");
			
		}
		
		function checkSubs(itemDiv, isChecked){
			if(isChecked){
				itemDiv.siblings().find(".item").addClass("active");
			}else{
				itemDiv.siblings().find(".item").removeClass("active");				
			}
		}
		
		
		function rowClick(div,e){
			e.stopPropagation();
			$(div).siblings().toggle();
		}
		
		function initNodes(){
			var tree = $("#tree");
			for(var i in nodeData){
				var item = nodeData[i];
				if(item.type == 't'){
					tree.append("<div class='row' id='"+item.type+"_"+item.id+"'><div class='item tea' data='"+item.id+"'  onclick='rowClick(this,event)'><a onclick='aClick(this,event)'></a><span>"+item.name+"</span></div></div>");
				
				}else if(item.type=="d1"){
					tree.append("<div class='row' id='"+item.type+"_"+item.id+"'><div class='item'  onclick='rowClick(this,event)'><span>"+item.name+"</span></div></div>");
							
				}			
			}
			
			for(var i in nodeData){
				var item = nodeData[i];
				var pidArray =(""+item.pid).split(",");
				for(var j in pidArray){
					moveTo(item.id,item.type,pidArray[j]);
				}
			}			
		}
		
		function submit(){
			var str = getSelectedIds();
			if(imgId==""){
				form1.submit();
			}else{
				//form1.submit();
				$.showLoading("正在上传...");
				wx.uploadImage({
		            localId: imgId, // 需要上传的图片的本地ID，由chooseImage接口获得
		            isShowProgressTips: 0, // 默认为1，显示进度提示
		            success: function (res) {
		                var serverId = res.serverId; // 返回图片的服务器端ID
		               $("#serverId").val(serverId);
						form1.submit();
		            },
		            fail:function(res){
	          			$.hideLoading();
	          			$.alert("上传失败");
		            }
		        });
			}
		}
		
		function getSelectedIds(){
			var id = $(".tea.active").first().attr("data");
			$("#targetId").val(id);
			return id;
		}
		
		function moveTo(id,type,pid){
			pid = "d1_"+pid;
			if($("#"+pid)){
				if($("#"+type+"_"+id).parent().attr("id")=="tree"){
					$("#"+type+"_"+id).appendTo($("#"+pid));
				}else{
					$("#"+type+"_"+id).clone().appendTo($("#"+pid));
				}
			}
		}
	jQuery(document).ready(function($) {
		wx.config({
		    debug: false, 
		    appId: '${appId}', 
		    timestamp: ${timestamp}, 
		    nonceStr: '${nonceStr}',
		    signature: '${signature}',
		    jsApiList: [
		                'chooseImage',
		                'previewImage',
		                'uploadImage'
		                ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
		});
		//${ori}
		wx.error(function(res){
			
		});
		initNodes();
		
	});
	
	</script>
	@}
</body>
</html>